package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAO.ZCDJ;

/**
 * Servlet implementation class updataAssetServlet
 */
public class updataAssetServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public updataAssetServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/plain");
		PrintWriter out = response.getWriter();	
		
		String asset[] = new String[10];  //数组 -- 存放修改资产信息的参数

		/*
		 * 资产信息可以修改的参数
		 */
	    asset[0] = request.getParameter("assetNo");
	    asset[1] = request.getParameter("assetName");
	    asset[2] = request.getParameter("assetBarcode");
	    asset[3] = request.getParameter("assetState");
	    asset[4] = request.getParameter("belongTo");
	    asset[5] = request.getParameter("comment");
	    asset[6] = request.getParameter("sku");
	    asset[7] = request.getParameter("deviceType");
/*	    asset[6] = request.getParameter("depreciation");
	    asset[7] = request.getParameter("appertainEquipment");
	    asset[8] = request.getParameter("equipNumber");
	    asset[9] = request.getParameter("model");
	    asset[10] = request.getParameter("type");
	    asset[11] = request.getParameter("produceDate");
	    asset[12] = request.getParameter("money");
	    asset[13] = request.getParameter("department");
	    asset[14] = request.getParameter("buildCharge");
	    asset[15] = request.getParameter("startUseTime");
	    asset[16] = request.getParameter("usedYears");
	    asset[17] = request.getParameter("lifeYears");
	    asset[18] = request.getParameter("remark");
	    asset[19] = request.getParameter("assetNo");*/
	    
	    System.out.println(".........." + asset[1]);
	    
	    /*
	     * 调用DAO里的updataAsset函数，将相关资产信息写入数据库
	     * 数组参数asset
	     */
	    ZCDJ zcdj = new ZCDJ();
	    zcdj.updataAsset(asset);

	    out.print("{success:true,msg:'succeed'}"); //应答		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
